package cn.mxz.xmu.restful.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import wang.mouge.common.util.encrypt.Encrypt;
import cn.mxz.xmu.restful.service.UniversityService;

/**
 * 与信息门户相关的功能的控制器
 * 
 * @author kangbin <kangbin@mouge.wang>
 * @since 2015-03-10
 */
@Scope("prototype")
@Controller
@RequestMapping("/university")
public class UniversityController
{
	private static final Logger LOG = LoggerFactory.getLogger(UniversityController.class);

	@Autowired
	private UniversityService service;

	@ResponseBody
	@RequestMapping(value = "/param/{method}/{schoolId}/{term}/{day}/{xiaoquId}/{louId}", method = RequestMethod.GET, produces = "text/plain;charset=UTF-8")
	public String param(@PathVariable String method, @PathVariable String schoolId, @PathVariable String term, @PathVariable String day, @PathVariable String xiaoquId, @PathVariable String louId)
	{
		String result = service.param(method, schoolId, Encrypt.hex2Dec(term), Encrypt.hex2Dec(day), Encrypt.hex2Dec(xiaoquId), Encrypt.hex2Dec(louId));
//		String result = service.param(method, schoolId, term, day, xiaoquId, louId);
		LOG.info("/param/" + method + "/" + schoolId + "/" + Encrypt.hex2Dec(day) + "/" + Encrypt.hex2Dec(xiaoquId) + "/" + Encrypt.hex2Dec(louId) + ":" + result);
		return result;
	}
}
